﻿<%@ Page Title="" Language="C#" MasterPageFile="~/pubadministration/main.Master" AutoEventWireup="true" CodeBehind="sales.aspx.cs" Inherits="comix.pubadministration.sales" %>
<%@ Register Assembly="BasicFrame.WebControls.BasicDatePicker" Namespace="BasicFrame.WebControls" TagPrefix="BDP" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<h3>Πωλήσεις Εντύπων</h3>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
Περίοδος:<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
        onselectedindexchanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem>Σήμερα</asp:ListItem>
        <asp:ListItem>Τελευταία Εβδομάδα</asp:ListItem>
        <asp:ListItem>Τελευταίος Μήνας</asp:ListItem>
        <asp:ListItem>Τελευταίο Έτος</asp:ListItem>
        <asp:ListItem>Τρέχον Μήνας</asp:ListItem>
        <asp:ListItem>Τρέχον Έτος</asp:ListItem>
        <asp:ListItem>Από-Μέχρι</asp:ListItem>
    </asp:DropDownList>
    &nbsp;&nbsp;Από:<BDP:BDPLite DateFormat="ShortDate" Width="50" ID="BDPfrom"  runat="server"  />&nbsp;&nbsp;Μέχρι:<BDP:BDPLite  DateFormat="ShortDate" Width="50" ID="BDPto"  runat="server"  />&nbsp;&nbsp;<asp:Button 
        ID="Button1" runat="server" Text="Ανανέωση" oncommand="Button1_Command" />
    <br /><br />
    <h3>Συναλλαγές Μέσω AppStore</h3>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
        DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" 
        onrowdatabound="GridView1_RowDataBound" ShowFooter="True">
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <Columns>
            <asp:BoundField DataField="bok_title" HeaderText="Τίτλος" 
                SortExpression="bok_title" >
            <ItemStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:BoundField DataField="cnt" HeaderText="Πλήθος " ReadOnly="True" 
                SortExpression="cnt" >
            <ItemStyle HorizontalAlign="Right" />
            </asp:BoundField>
            <asp:BoundField DataField="total_price" HeaderText="Συνολική Τιμή" 
                ReadOnly="True" SortExpression="total_price">
            <ItemStyle HorizontalAlign="Right" />
            </asp:BoundField>
            <asp:BoundField DataField="net_price" HeaderText="Καθαρή Τιμή" 
                ReadOnly="True" SortExpression="net_price">
            <ItemStyle HorizontalAlign="Right" />
            </asp:BoundField> 
            <asp:BoundField DataField="pub_price" HeaderText="Εισπρακτέα" 
                ReadOnly="True" SortExpression="pub_price">
            <ItemStyle HorizontalAlign="Right" />
            </asp:BoundField>                        
        </Columns>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" HorizontalAlign="Right" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#999999" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:mainconectionstring %>" 
        
        SelectCommand="SELECT BOOKS.bok_title, COUNT(TRANSACTIONS.trs_id) AS cnt,  SUM(TRANSACTIONS.trs_price) AS total_price, SUM(TRANSACTIONS.trs_netprice) AS net_price, CONVERT(decimal(18,2),SUM(TRANSACTIONS.trs_netprice)*pub_percentage) AS pub_price  FROM BOOKS INNER JOIN SERIES ON BOOKS.bok_ser_id = SERIES.ser_id INNER JOIN PUBLISHERS on pub_id = ser_pub_id INNER JOIN TRANSACTIONS ON BOOKS.bok_id = TRANSACTIONS.trs_bok_id  WHERE (SERIES.ser_pub_id = @ser_pub_id) AND (TRANSACTIONS.trs_date &gt;= @from_date) AND (TRANSACTIONS.trs_date &lt;= @to_date) AND trs_origin = 1 GROUP BY BOOKS.bok_title, pub_percentage">
        <SelectParameters>
            <asp:SessionParameter Name="ser_pub_id" SessionField="user" />
            <asp:SessionParameter Name="from_date" SessionField="dtfrom" />
            <asp:SessionParameter Name="to_date" SessionField="dtto" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
